﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace dbPoll_Application.Models
{
    public class Role
    {
        public virtual String RoleName { get; set; }
        public virtual Role CanCreate { get; set; }
        public virtual ICollection<Role> InheritedRoles { get; set; }

        public Role()
        {
            this.RoleName = String.Empty;
            this.CanCreate = null;
            this.InheritedRoles = null;
        }

        public Role(String roleName)
        {
            this.RoleName = roleName;
            this.CanCreate = null;
            this.InheritedRoles = new HashSet<Role>();
        }

        public override bool Equals(Object obj)
        {
            if (obj == null)
            {
                return false;
            }
            var role = obj as Role;
            if ((System.Object)role == null)
            {
                return false;
            }
            return this.RoleName == role.RoleName;
        }

        public override int GetHashCode()
        {
            return string.Format("{0}", RoleName).GetHashCode();
        }
    }
}
